<template>
    <el-card header="首页">
        <div class="dash-content">
            <div class="overview">

                <div class="boxes">
                    <div class="box box1">
                        <i>
                            <FaUserLarge />
                        </i>
                        <div>
                            <h3 class="text">用户</h3>
                            <span class="number">{{ user }}</span>
                        </div>
                    </div>
                    <div class="box box1">
                        <i>
                            <BsImage />
                        </i>
                        <div>
                            <h3 class="text">图片</h3>
                            <span class="number">{{ img }}</span>
                        </div>
                    </div>
                    <div class="box box1">
                        <i>
                            <MdOutlinedArticle />
                        </i>
                        <div>
                            <h3 class="text">文章</h3>
                            <span class="number">{{ article }}</span>
                        </div>
                    </div>
                    <div class="box box1">
                        <i>
                            <IcCity />
                        </i>
                        <div>
                            <h3 class="text">城市</h3>
                            <span class="number">{{ city }}</span>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </el-card>
</template>

<script setup>
import { ref, reactive } from 'vue';
import { FaUserLarge, BsImage, IcCity, MdOutlinedArticle } from '@kalimahapps/vue-icons';
import { getArticleListAPI, galleryListAPI, cityListAPI, getUserLIstAPI } from '@/api/index.js'

let city = ref(0)
let img = ref(0)
let user = ref(0)
let article = ref(0)
const ListDto = reactive({
    pageSize: 10,
    pageNum: 1
})
const initData = async () => {
    const articleList = await getArticleListAPI(ListDto)
    article.value = articleList.total
    const gallery = await galleryListAPI(ListDto)
    img.value = gallery.total
    const userList = await getUserLIstAPI(ListDto)
    const cityList = await cityListAPI(ListDto)
    user.value = userList.total
    city.value = cityList.total
}
initData()

</script>

<style lang="scss" scoped>
.dashboard .dash-content {
    padding-top: 50px;
}

.dash-content .overview .boxes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr));
    gap: 2rem;
}

.dash-content .overview .boxes .box {
    display: flex;
    justify-content: space-between;
    padding: 15px 25px;
    background: #eee;
}

.overview .boxes .box i {
    font-size: 75px;
    display: flex;
    align-items: center;
    color: #222;
}

.boxes .box .text {
    white-space: nowrap;
    font-size: 30px;
    color: #777;
}

.boxes .box .number {
    font-size: 30px;
    color: #777;
}

@media (max-width:768px) {
    .overview .boxes .box i {
        font-size: 40px;
    }

    .boxes .box .text {
        white-space: nowrap;
        font-size: 40px;
        color: #777;
    }

    .boxes .box .number {
        font-size: 40px;
        color: #777;
    }
}

@media (max-width:450px) {
    .dash-content .overview .boxes {
        grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
    }

    .overview .boxes .box i {
        font-size: 20px;
    }

    .boxes .box .text {
        white-space: nowrap;
        font-size: 10px;
        color: #777;
    }

    .boxes .box .number {
        font-size: 20px;
        color: #777;
    }
}
</style>